package cn.stylefeng.guns.modular.ry600.controller;

import cn.stylefeng.roses.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import cn.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import cn.stylefeng.guns.modular.system.model.Ordercheck;
import cn.stylefeng.guns.modular.ry600.service.IOrdercheckService;

/**
 * 订单推送检查控制器
 *
 * @author fengshuonan
 * @Date 2019-01-14 11:31:03
 */
@Controller
@RequestMapping("/ordercheck")
public class OrdercheckController extends BaseController {

    private String PREFIX = "/ry600/ordercheck/";

    @Autowired
    private IOrdercheckService ordercheckService;

    /**
     * 跳转到订单推送检查首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "ordercheck.html";
    }

    /**
     * 跳转到添加订单推送检查
     */
    @RequestMapping("/ordercheck_add")
    public String ordercheckAdd() {
        return PREFIX + "ordercheck_add.html";
    }

    /**
     * 跳转到修改订单推送检查
     */
    @RequestMapping("/ordercheck_update/{ordercheckId}")
    public String ordercheckUpdate(@PathVariable Integer ordercheckId, Model model) {
        Ordercheck ordercheck = ordercheckService.selectById(ordercheckId);
        model.addAttribute("item",ordercheck);
        LogObjectHolder.me().set(ordercheck);
        return PREFIX + "ordercheck_edit.html";
    }

    /**
     * 获取订单推送检查列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return ordercheckService.selectList(null);
    }

    /**
     * 新增订单推送检查
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(Ordercheck ordercheck) {
        ordercheckService.insert(ordercheck);
        return SUCCESS_TIP;
    }

    /**
     * 删除订单推送检查
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer ordercheckId) {
        ordercheckService.deleteById(ordercheckId);
        return SUCCESS_TIP;
    }

    /**
     * 修改订单推送检查
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(Ordercheck ordercheck) {
        ordercheckService.updateById(ordercheck);
        return SUCCESS_TIP;
    }

    /**
     * 订单推送检查详情
     */
    @RequestMapping(value = "/detail/{ordercheckId}")
    @ResponseBody
    public Object detail(@PathVariable("ordercheckId") Integer ordercheckId) {
        return ordercheckService.selectById(ordercheckId);
    }
}
